# encoding: utf-8
"""
Notify Modules
=======

Modules enable logical resource separation.

You may control enabled modules by modifying ``ENABLED_MODULES`` config
variable.
"""
from config import BaseConfig

scheduler = None


def init_app(app, **kwargs):
    """
    Init redises module.
    """
    from apscheduler.schedulers.background import BackgroundScheduler
    from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
    from apscheduler.executors.pool import ThreadPoolExecutor
    jobstores = {
        'default': SQLAlchemyJobStore(url=BaseConfig.SQLALCHEMY_DATABASE_URI)
    }
    executors = {
        'default': ThreadPoolExecutor(1),
        'single': ThreadPoolExecutor(2)
    }
    job_defaults = {
        'coalesce': False,
        'max_instances': 3
    }
    global scheduler
    scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults)
    import schedules
    scheduler.start()
    pass